// 引入Sequelize模块
const Sequelize = require('sequelize');

// 引入数据库实例
const db = require('../db');

const bgSetting = db.define("bgSetting", {
    // 主键
    objectId: {
        type: Sequelize.INTEGER,
        allowNull: false,
        unique: true,
        primaryKey: true,
        autoIncrement: true,
    },

    canIn: {
        type: Sequelize.BOOLEAN,
        defaultValue: true,
    },

    videoId: {
        type: Sequelize.STRING,
        defaultValue: '',
    },

    source: {
        type: Sequelize.JSON,
        defaultValue: [],
    },

    createdAt: {
        type: Sequelize.DATE,
        get() {
            const rawValue = this.getDataValue('createdAt');
            return dateFormat(rawValue, 'yyyy-mm-dd HH:MM:ss');
        }
    },

    updatedAt: {
        type: Sequelize.DATE,
        get() {
            const rawValue = this.getDataValue('updatedAt');
            return dateFormat(rawValue, 'yyyy-mm-dd HH:MM:ss');
        }
    },

}, {
    // 是否支持驼峰
    underscored: false,
    // MySQL数据库表名
    tableName: "bgSetting",
});

(async () => {
   /* bgSetting.sync({
        alter: true
    });

    console.log("后台设置表同步成功")*/
})();

module.exports = bgSetting;
